package com.shop.controller;

import com.shop.domain.Ad;
import com.shop.entity.Result;
import com.shop.service.AdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 广告表
 */
@RestController
@RequestMapping("/Ad")
public class AdController {
    @Autowired
    private AdService iAdService;
    /**
     * 查询全部广告表
     * @param
     * @return
     */
    @GetMapping("/selectAll")
    public Result<List<Ad>> selectAll(){
        return new Result<>("查询成功",iAdService.selectAll());
    }


    /**
     * 条件查询广告表
     * @param iAd
     * @return
     */
    @PostMapping("/selectList")
    public Result< List<Ad> > select(@RequestBody Ad iAd){
        return new Result<>("条件查询成功",iAdService.selectList(iAd));
    }

    /**
     * 新增广告表
     * @param iAd
     * @return
     */
    @PostMapping("/insert")
    public Result insert(@RequestBody Ad iAd){
        iAdService.insert(iAd);
        return new Result<>("新增成功");
    }


    /**
     * 删除广告表
     * @param ids
     * @return
     */
    @GetMapping("/delete")
    public Result delete(@RequestParam String ids){
        iAdService.delete(ids);
        return new Result<>("删除成功");
    }


    /**
     * 修改广告表
     * @param iAd
     * @return
     */
    @PostMapping("/update")
    public Result update(@RequestBody Ad iAd){
        iAdService.update(iAd);
        return new Result<>("修改成功");
    }

}
